//
//  parser.c
//  
//  parser
//
//  Created by Pei Liu on 10/25/11.
//  Copyright 2011 FOR CS 440. All rights reserved.
//

#include "parser.h"

/*change id to number of procedure and @*/
char* changeid(char* in)
{
	/*add distinguisher*/
	char* temp;
	temp = (char*)malloc((strlen(in) + 2) * sizeof(char));
	
	int i = 0;
	for(i = 0; i < strlen(in); i++)
	{
		temp[i] = in[i];
	}
	
	
	temp[i] = '@';
    //add which procedure belong to
	temp[i+1] = (char)(procounter[cur_proc] + '0');
	temp[i+2] = 0;
	
	return temp;
}

/* store opcode into the code store*/
void emit(int opcode, int operand1, int operand2)
{
    store_int(opcode, cur_cs++, cs);
    store_int(operand1, cur_cs++, cs);
    store_int(operand2, cur_cs++, cs);
    
}